(SST) ShlWAPI.pas Version 1.08

Developer Reference
(SST)ShlWAPI PathIsSystemFolder Function
Checks if the file system attributes qualify the file system object, referenced by the specified path string, as a system folder.
Scope
Global (i.e. this function can be called/accessed from code in any unit that includes/uses (SST)ShlWAPI.pas).
Syntax
function PathIsSystemFolder(pszPath : LPCSTR; dwAttrb : DWORD) : BOOL;
Parameters
pszPath [in] Pointer to a NULL terminated string that is the path to the folder to check. This string, including the terminating NULL character, should not exceed MAX_PATH (= 260 chars.) in length.
dwAttrb [in] A combination of file system attributes to be tested as qualifying a folder as a system folder, in lieu of the path.
Return Values
The function returns TRUE if either the file system object's or the specified (file) attributes qualify it as a system folder.
Remarks
The basic idea behind this function appears to have been to retrieve the attributes of an arbitrary file system object and pass both the path string and attributes to this function to determine if it's a system folder. This functionality is presumably used to hide system folders from the user in Windows Explorer if it has been configured not to display system files.
Example
PROCEDURE TForm4.TestShlWAPIPathIsSystemFolder(Sender : TObject); VAR pathtotest : STRING; VAR fileattributes : DWORD; VAR apiretval : BOOL; VAR newinfoline : STRING; BEGIN pathtotest := ''; fileattributes := 0; apiretval := FALSE; newinfoline := ''; pathtotest := 'C:\Windows\System32'; fileattributes := GetFileAttributes(PChar(pathtotest)); newinfoline := 'PathIsSystemFolder called with ' + pathtotest + ' (attributes: 0x' + IntToHex(fileattributes, 8) + ') and FILE_ATTRIBUTE_SYSTEM'; Memo1.Lines.Add(newinfoline); fileattributes := FILE_ATTRIBUTE_SYSTEM; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'C:\Hello\World'; //Non-existent path ! fileattributes := GetFileAttributes(PChar(pathtotest)); newinfoline := 'PathIsSystemFolder called with ' + pathtotest + ' (attributes: 0x' + IntToHex(fileattributes, 8) + ') and 0'; Memo1.Lines.Add(newinfoline); fileattributes := 0; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'C:\Windows\System32\Microsoft'; fileattributes := GetFileAttributes(PChar(pathtotest)); newinfoline := 'PathIsSystemFolder called with ' + pathtotest + ' (attributes: 0x' + IntToHex(fileattributes, 8) + ') and FILE_ATTRIBUTE_SYSTEM'; Memo1.Lines.Add(newinfoline); fileattributes := FILE_ATTRIBUTE_SYSTEM; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'C:\Windows\System32\Microsoft'; fileattributes := GetFileAttributes(PChar(pathtotest)); newinfoline := 'PathIsSystemFolder called with ' + pathtotest + ' (attributes: 0x' + IntToHex(fileattributes, 8) + ') and 0'; Memo1.Lines.Add(newinfoline); fileattributes := 0; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'C:\Windows\System32\ShlWAPI.dll'; //Call with file instead of folder fileattributes := GetFileAttributes(PChar(pathtotest)); newinfoline := 'PathIsSystemFolder called with ' + pathtotest + ' (attributes: 0x' + IntToHex(fileattributes, 8) + ') and FILE_ATTRIBUTE_ARCHIVE'; Memo1.Lines.Add(newinfoline); fileattributes := FILE_ATTRIBUTE_ARCHIVE; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := 'C:\Windows\System'; fileattributes := GetFileAttributes(PChar(pathtotest)); newinfoline := 'PathIsSystemFolder called with ' + pathtotest + ' (attributes: 0x' + IntToHex(fileattributes, 8) + ') and FILE_ATTRIBUTE_READONLY'; Memo1.Lines.Add(newinfoline); fileattributes := FILE_ATTRIBUTE_READONLY; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); pathtotest := ''; newinfoline := 'PathIsSystemFolder called with an empty string ' + ' and FILE_ATTRIBUTE_SYSTEM OR FILE_ATTRIBUTE_DIRECTORY'; Memo1.Lines.Add(newinfoline); fileattributes := FILE_ATTRIBUTE_SYSTEM OR FILE_ATTRIBUTE_DIRECTORY; apiretval := PathIsSystemFolder(PChar(pathtotest), fileattributes); IF apiretval THEN newinfoline := 'TRUE' ELSE newinfoline := 'FALSE'; Memo1.Lines.Add(newinfoline); Memo1.Lines.Add(''); END;
PathIsSystemFolder called with C:\Windows\System32 (attributes: 0x00002010) and FILE_ATTRIBUTE_SYSTEM FALSE PathIsSystemFolder called with C:\Hello\World (attributes: 0xFFFFFFFF) and 0 FALSE PathIsSystemFolder called with C:\Windows\System32\Microsoft (attributes: 0x00002014) and FILE_ATTRIBUTE_SYSTEM TRUE PathIsSystemFolder called with C:\Windows\System32\Microsoft (attributes: 0x00002014) and 0 TRUE PathIsSystemFolder called with C:\Windows\System32\ShlWAPI.dll (attributes: 0x00000020) and FILE_ATTRIBUTE_ARCHIVE FALSE PathIsSystemFolder called with C:\Windows\System (attributes: 0x00002010) and FILE_ATTRIBUTE_READONLY FALSE PathIsSystemFolder called with an empty string and FILE_ATTRIBUTE_SYSTEM OR FILE_ATTRIBUTE_DIRECTORY TRUE
Requirements
Unit: Declared and imported in (SST)ShlWAPI.pas
Library: (SST)ShlWAPI.dcu/(SST)ShlWAPI.obj
Unicode: Implemented as ANSI (PathIsSystemFolder and PathIsSystemFolderA) and Unicode (PathIsSystemFolderW) functions.
Min. ShlWAPI.dll version according to MS SDK doc.: 4.71
Min. ShlWAPI.dll version based on SST research: 4.71
Min. OS version(s) according to Microsoft SDK doc.: Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0
Min. OS version(s) according to SST research.: Windows NT 4.0 with IE 4.0, Windows 95 with IE 4.0, Windows 98, Windows 2000 and later
See Also
PathIsDirectory, PathFileExists.
 
Windows APIs: PathIsSystemFolder, PathIsDirectory PathFileExists.


Document/Contents version 1.02
Page/URI last updated on 07.12.2023
 
Copyright © Stoelzel Software Technologie (SST) 2018 - 2022
Suggestions and comments mail to:
webmaster@stoelzelsoftwaretech.com